package com.mark.web.sys.service.impl;

import com.mark.web.sys.entity.po.Dict;
import com.mark.web.sys.entity.vo.DictVo;
import com.mark.web.sys.mapper.DictMapper;
import com.mark.web.sys.service.IDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description: 字典管理的Service层接口实现
 * @Author: Mark
 * @CreateDate: 2019/6/8 19:14
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
@Service
public class DictServiceImpl implements IDictService {

    private final DictMapper dictMapper;

    @Autowired
    public DictServiceImpl(DictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    @Override
    public List<DictVo> getDictByParentId(int parentId) {
        List<Dict> dictList = dictMapper.selectByParentId(parentId);
        return dictList
                .stream()
                .map(DictVo::new)
                .collect(Collectors.toList());
    }
}
